const host = 'https://han96.com'

class Api {
	get(url, data) {
		return new Promise((reslove, reject) => {
			uni.request({
				url: host + '/api' + url,
				data: data,
				header: {

				},
				success(res) {
					const code = res.data.code
					if (code == 401) {
						uni.showModal({
							title: '登录提示',
							content: res.data.msg,
							success: function(e) {
								if (e.confirm) {
									uni.navigateTo({
										url: '/pages/login/index'
									})
								}
							}
						})
					}
					reslove(res.data)
				},
				fail() {
					reject('请求失败')
				}
			});
		})
	}
}


export default new Api()
